//
//  TCPSocket.hpp
//  MultiPlayer
//
//  Created by 星落之尘 on 2020/6/9.
//  Copyright © 2020 Tan. All rights reserved.
//   1/需要建立链接 connect
//   2/服务器需要绑定ip，port
//   3/ 监听握手状态
//   4/ accept 握手成功，返回新的socket对象
//   5/ send发送数据， receive 接受数据


#include "RoboCatPch.h"
class TCPSocket
{
public:
    ~TCPSocket();
    int                                Connect( const SocketAddress& inAddress );
    int                                Bind( const SocketAddress& inToAddress );
    int                                Listen( int inBackLog = 32 );
    shared_ptr< TCPSocket >            Accept( SocketAddress& inFromAddress );
    int32_t                            Send( const void* inData, size_t inLen );
                    
    int32_t                            Receive( void* inBuffer, size_t inLen );
private:
    friend class SocketUtil;
    TCPSocket( SOCKET inSocket ) : mSocket( inSocket ) {}
    SOCKET        mSocket;
};
typedef shared_ptr< TCPSocket > TCPSocketPtr;


